import os,shutil

src = "/mnt/data/people/cocoDataset/JPEGImages"


for num,img in enumerate(sorted(os.listdir(src),key=lambda b:int(b.split(".")[0])     )):
    if(num%5000 == 0):
        dst = src+"_"+str(num+5000)
        os.mkdir(dst)

    imgPath = os.path.join(src,img)
    shutil.move(imgPath,dst)
    print(img)